package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageDto;
import com.heima.wemedia.service.IWmNewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 自媒体图文内容信息表 前端控制器
 * </p>
 *
 * @author chana
 * @since 2024-08-15
 */
@RestController
@RequestMapping("/api/v1/news")
@Api("自媒体图文内容信息")
public class WmNewsController {

    @Resource
    private IWmNewsService iWmNewsService;

    @PostMapping("/submit")
    @ApiOperation("提交文章")
    public ResponseResult submit(@RequestBody WmNewsDto dto){
        return  iWmNewsService.submit(dto);
    }

    @PostMapping("/list")
    @ApiOperation("查询文章")
    public ResponseResult listAndPage(@RequestBody WmNewsPageDto dto){
        return iWmNewsService.listAndPage(dto);
    }

    @GetMapping("/del_news/{id}")
    @ApiOperation("逻辑删除文章")
    public ResponseResult delNews(@PathVariable("id") Integer id){
        return iWmNewsService.delNews(id);
    }

    @GetMapping("/one/{id}")
    @ApiOperation("根据iD查找文章")
    public ResponseResult selectById(@PathVariable("id") Integer id){
        return iWmNewsService.selectById(id);
    }

    @PostMapping("/down_or_up")
    @ApiOperation("下架文章")
    public ResponseResult downOrUp(@RequestBody WmNewsDto dto){
        return iWmNewsService.downOrUp(dto);
    }
}
